package com.java.basis.io.stream.inputoroutstream;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;

/**
 * @author wangning
 * @create 2021-06-11 15:44
 * 文件读取，中文乱码解决
 */
public class Test03 {
	public static void main(String[] args) throws Exception {
		FileInputStream in = null;
		try {
			in = new FileInputStream("F:/jt/file/testinputstream.txt");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		InputStreamReader reader = new InputStreamReader(in, "UTF-8");//charsetName是文件的编码格式，根据文件属性而定

		BufferedReader br = new BufferedReader(reader);
		String s;
		while ((s = br.readLine()) != null) {
			System.out.println(s);
		}
		String t;
		while ((t = br.readLine()) != null) {
			System.out.println(t);
		}

//		int n;
//		while ((n = reader.read()) != -1) {
//			char c = (char) n;
//			System.out.print(c);
//		}

		br.close();
		reader.close();
		in.close();
	}
}
